package model;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

import controller.MisterJumpController;

public class Platform extends Thing implements Item
{
	
	public Platform(double cX, double cY) throws SlickException
	{
		super(cX, cY);
		image = new Image("data/standard_platform.png");
		setWidth(.25);
		setHeight(.03);
		if (getX() + getWidth() > 1)
		{
			setX(1-getWidth());
		}
	}
	
	public Type getType()
	{
		return Type.STANDARD;
	}
	
	public boolean misterJumpsOn()
	{
		
		Wrapper model = Wrapper.getInstance();
		double vMister = model.getMisterYGeschwindigkeit();
		double xMister = model.getMisterX();
		double yMister = model.getMisterY();
		double wMister = model.getMisterWidth();
		double hMister = model.getMisterHeight();
		
		if (model.getMisterYGeschwindigkeit() < 0)
		{
			if (!MisterJumpController.collisionDetected(xMister, yMister, wMister, hMister, this.getX(), this.getY(), this.getWidth(), this.getHeight())
					&& MisterJumpController.collisionDetected(xMister, yMister + vMister, wMister, hMister, this.getX(), this.getY(), this.getWidth(), this.getHeight()))
			{
				return true; 
			}
		}
		return false;
		// TODO Auto-generated method stub
		
	}

	@Override
	public void act()
	{
		if (misterJumpsOn())
		{
			Wrapper.getInstance().setMisterYGeschwindigkeit(0.02);
		}
	}
	
}
